# 导入flask
from flask import Flask
from flask import request,json
#导入时间模块
import time
# from flask.wrappers import request

from pymysql.connections import DEBUG

# 建立flask实例
app = Flask(__name__)
# 解决中文乱码
app.config['JSON_AS_ASCII']=False

# 试图
#不加methods 默认GET请求方式  支持8种   不写默认支持1中GET
@app.route('/',methods=['GET','POST','PUT','DELETE'])
async def hello_word():
    
    #通过url传参
    # data = request.args.get('id')
    # print(data)
    #post 通过form表单传参
    data = request.form.get('id')
    print(data)

    return {"code":200,'msg':'你好世界'}

# 耗时任务
async def get_data():
    time.sleep(5)

# 性能接口
@app.route('/data/')
async def mydata():
    print('开始执行')
    time.sleep(5)
    await get_data()
    print("执行结束")

    return{"msg":'执行结束'}

# 调用实例对象
if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0',port=5000)


